﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WikiTrailCreator.TrailImages
{
    public class ImageGallery
    {
        private List<TrailImage> images = new List<TrailImage>();

        public event EventHandler GalleryChanged;

        /// <summary>
        /// Constructor.
        /// </summary>
        public ImageGallery()
        {
            // Nothing here...
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="imagesInGallery">Images starting in the gallery.</param>
        public ImageGallery(TrailImage[] imagesInGallery)
        {
            images.AddRange(imagesInGallery);
        }

        /// <summary>
        /// Images available in this gallery in the proper order.
        /// </summary>
        public TrailImage[] Images
        {
            get
            {
                return images.ToArray();
            }
            set
            {
                images.Clear();

                if (value != null)
                {
                    images.AddRange(value);
                }

                OnGalleryChanged();
            }
        }

        public void OnGalleryChanged()
        {
            if (GalleryChanged != null)
            {
                GalleryChanged(this, new EventArgs());
            }
        }
    }
}
